import { ApiCall } from "tsrpc";
import { ReqRename, ResRename } from "../../../../shared/master/body/pet/PtlRename";
import { player } from "../../../../model/fight/body/player";
import { template } from "../../../../shared/master/MsgAction";

export default async function (call: ApiCall<ReqRename, ResRename>) {
    call.succ({});
    let user = call.req._player as player;
    let pets = user.getPets();
    if(!pets[call.req.idx - 1]){
        user.sendMsg(template.default,`没有找到ID为${call.req.idx}的宠物`)
        return;
    }
    user.sendMsg(template.default,`宠物已改名为${call.req.name}`);
    pets[call.req.idx - 1].reName(call.req.name);
}